import time
import multiprocessing


def working():
    for i in range(10):
        print(i)
        time.sleep(0.2)

if __name__ == '__main__':
    sub_process = multiprocessing.Process(target=working)
    # 启动子进程
    sub_process.start()

    time.sleep(1)
    # 在主进程退出之前，销毁所有的子进程
    sub_process.terminate()
    print('主进程结束')

